import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WalletVO, WalletForm, WalletQuery } from '@/api/retail/wallet/types';

/**
 * 查询钱包列表
 * @param query
 * @returns {*}
 */

export const listWallet = (query?: WalletQuery): AxiosPromise<WalletVO[]> => {
  return request({
    url: '/retail/wallet/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询钱包详细
 * @param id
 */
export const getWallet = (id: string | number): AxiosPromise<WalletVO> => {
  return request({
    url: '/retail/wallet/' + id,
    method: 'get'
  });
};

/**
 * 新增钱包
 * @param data
 */
export const addWallet = (data: WalletForm) => {
  return request({
    url: '/retail/wallet',
    method: 'post',
    data: data
  });
};

/**
 * 修改钱包
 * @param data
 */
export const updateWallet = (data: WalletForm) => {
  return request({
    url: '/retail/wallet',
    method: 'put',
    data: data
  });
};

/**
 * 删除钱包
 * @param id
 */
export const delWallet = (id: string | number | Array<string | number>) => {
  return request({
    url: '/retail/wallet/' + id,
    method: 'delete'
  });
};
